#include <bits/stdc++.h>
// 2025/01/21
// tag: 
// Author: Zhang Muen
using namespace std;

class UF
{
public:
    vector<int> parents, money, value;
    int cnt;

    UF(int n)
    {
        cnt = n;
        for (int i = 0; i < n; i++)
            parents.push_back(i);
        money = vector<int>(n, 0);
        value = vector<int>(n, 0);
    };

    int find(int i)
    {
        if (parents[i] != i)
            return parents[i] = find(parents[i]);
        return parents[i];
    }

    void un(int i, int j)
    {
        int ri = find(i), rj = find(j);
        if (ri == rj)
            return;
        parents[ri] = rj, money[rj] += money[ri], value[rj] += value[ri];
        cnt--;
    }

    int count()
    {
        return cnt;
    }

    bool connected(int p, int q)
    {
        return find(p) == find(q);
    }
};

int n, m, v;
int money[10001], value[10001], dp[10001];

signed main()
{
    cin >> n >> m >> v;
    UF uf(n + 1);
    for (int i = 1; i <= n; i++){
        int c, d;
        cin >> c >> d;
        uf.money[i] = c;
        uf.value[i] = d;
    }
    for (int i = 1; i <= m; i++){
        int a, b;
        cin >> a >> b;
        uf.un(a, b);
    }
    unordered_set<int> p;
    int cnt = 0;
    for (int i = 1; i <= n; i++){
        int r = uf.find(i);
        if (p.count(r))
            continue;
        p.insert(r);
        money[++cnt] = uf.money[r];
        value[cnt] = uf.value[r];
    }
    for (int i = 1; i <= cnt; i++)
        for (int j = v; j >= money[i]; j--)
            dp[j] = max(dp[j], dp[j - money[i]] + value[i]);
    cout << dp[v];
    return 0;
}